package com.example.demo.processor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

//@Component
@Slf4j
public class CustomProcessor implements BeanPostProcessor {


    /**
     * 执行顺序
     * 1、BeanPostProcessor 的 postProcessBeforeInitialization 前置方法调用
     * 2、InitializingBean afterPropertiesSet 自定义实现bean初始化方法
     * 3、Bean 自己定义的 init-method 方法
     * 4、BeanPostProcessor 的 postProcessAfterInitialization 后置方法调用
     *
     * */

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        log.info(beanName+"____前置方法");
        return null;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        log.info(beanName+"____后置方法");
        return null;
    }
}
